package pers.xiaojun.boot.module.system.controller.captcha;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.xiaojun.boot.common.pojo.CommonResult;
import pers.xiaojun.boot.module.system.controller.captcha.vo.CaptchaRespVO;
import pers.xiaojun.boot.module.system.service.capthca.CaptchaService;
import pers.xiaojun.boot.tenant.core.annotation.TenantIgnore;
import pers.xiaojun.boot.web.core.annotation.AdminApi;

/**
 * 验证码控制层
 *
 * @author xiaojun
 * @since 2025-10-06
 */
@Tag(name = "验证码")
@AdminApi
@RestController
@RequestMapping("/system/captcha")
@RequiredArgsConstructor
public class CaptchaController {

    private final CaptchaService captchaService;

    @TenantIgnore
    @GetMapping("/image")
    @PermitAll
    @Operation(summary = "获取图片验证码")
    public CommonResult<CaptchaRespVO> getCaptchaImage() {
        return CommonResult.success(captchaService.getCaptcha());
    }

}
